]> git.dpolakovic.space - htcpcp-requestor/commitdiff
perf: Removed redundant print_request sub. master
authorDavid Polakovic
Mon, 9 Mar 2026 13:18:27 +0000 (14:18 +0100)
committerDavid Polakovic
Mon, 9 Mar 2026 13:18:27 +0000 (14:18 +0100)
get-coffee-from

index 014e3ad55c8117207f41f85a84764b3e63c2a205..5f31407bff2acf1221acf398c7e4bb60dcb3557c 100644 (file)
@@ -26,12 +26,6 @@ sub request_code {
     return $res->code;
 }
 
     return $res->code;
 }
 
-sub teapot {
-    print "\nThis server is a teapot.\n";
-    print "As per RFC 2324 section 2.3.2: This server is a teapot and refuses to brew coffee.\n";
-    print "It may brew tea instead, but coffee is beyond its capabilities.\n";
-}
-
 # curl -X behaviour: sends request with specified method, returns body
 sub request_body {
     my ($method, $url) = @_;
 # curl -X behaviour: sends request with specified method, returns body
 sub request_body {
     my ($method, $url) = @_;
@@ -43,6 +37,12 @@ sub request_body {
     return $res->content;
 }
 
     return $res->content;
 }
 
+sub teapot {
+    print "\nThis server is a teapot.\n";
+    print "As per RFC 2324 section 2.3.2: This server is a teapot and refuses to brew coffee.\n";
+    print "It may brew tea instead, but coffee is beyond its capabilities.\n";
+}
+
 # find webmaster email in page body
 sub find_webmaster_email {
     my ($url) = @_;
 # find webmaster email in page body
 sub find_webmaster_email {
     my ($url) = @_;
@@ -76,18 +76,6 @@ sub no_coffee {
     }
 }
 
     }
 }
 
-sub print_response {
-    my ($method, $url) = @_;
-
-    my $ua  = LWP::UserAgent->new(max_redirect => 0, timeout => 10);
-    my $req = HTTP::Request->new(uc($method) => $url);
-    my $res = $ua->request($req);
-
-    # print "Status : " . $res->status_line . "\n";
-    # print "Headers:\n" . $res->headers->as_string . "\n";
-    print $res->content . "\n" if $res->content;
-}
-
 ## meat
 
 # get the domain
 ## meat
 
 # get the domain
@@ -148,10 +136,10 @@ sub good_manners {
 
 # decision tree
 if ($http_brew == 200) {
 
 # decision tree
 if ($http_brew == 200) {
-    print_response('BREW', $http_domain);
+    print request_body('BREW', $http_domain);print "\n";
     good_manners('http');
 } elsif ($https_brew == 200) {
     good_manners('http');
 } elsif ($https_brew == 200) {
-    print_response('BREW', $https_domain);
+    print request_body('BREW', $https_domain);print "\n";
     good_manners('https');
 } elsif ($http_brew == 418 || $https_brew == 418) {
     teapot();
     good_manners('https');
 } elsif ($http_brew == 418 || $https_brew == 418) {
     teapot();
Copyright 2022-2026 David Polakovic. Individual project licenses are located in project root in full length.

Site generated using Gitweb. Read the documentation for JavaScript and cookie information. Additional source code available here under GPLv3 license.

Server for this subdomain is RFC 2324 compliant